package ru.jexp.rcp.supply.swtext;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;

import ru.jexp.mvc.HandlerMap;

public class HandlerAction extends Action
{
	private String eventId;
	private HandlerMap handlers;

	public HandlerAction(String name, String eventId, HandlerMap handlers)
	{
		this(name, eventId, null, handlers);

	}

	public HandlerAction(String name, String eventId, ImageDescriptor descriptor, HandlerMap handlers)
	{
		setText(name);
		setToolTipText(name);
		setImageDescriptor(descriptor);
		setId(eventId);
		this.eventId = eventId;
		this.handlers = handlers;
	}

	@Override
	public void run()
	{
		handlers.handle(eventId);
	}
}
